package com.ahwei.common.mybatis.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;

/**
 * @Author：ahWei
 * Email: ahwei163@qq.com
 * Date: 2022-04-19 21:13:45
 * Description: 这是一个Java文件！
 */
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {

    /**
     * 使用mp实现添加操作执行
     * @param metaObject `
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        // 起始版本 3.3.3(推荐)
        this.strictInsertFill(metaObject, "gmtCreate", LocalDateTime::now, LocalDateTime.class);
        this.strictInsertFill(metaObject, "gmtModified", LocalDateTime::now, LocalDateTime.class);
   }



    /**
     * 使用mp实现更新操作执行
     * @param metaObject `
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "gmtModified", LocalDateTime::now, LocalDateTime.class);
    }
}
